package com.qf.dto;/*
 *徐韬
 *2021/10/25
 *20:18
 */

import com.fasterxml.jackson.annotation.JsonInclude;
import com.qf.constons.resultCode;
@JsonInclude(JsonInclude.Include.NON_EMPTY)//空的数据不会返回
public class R {
    private Integer code;//状态码 通过状态码我们可以告诉客户端具体状态
    private String msg;//状态描述
    private Object data;//当前返回的数据

public static R setOk(){
//    R r =new R();
//    r.setCode(resultCode.SUCCESS);
//    r.setMsg("成功");
    return setOk(null);
}
    public static R setOk(Object data){
        R r =new R();
        r.setCode(resultCode.SUCCESS);
        r.setMsg("成功");
        r.setData(data);
        return r;
    }
    public static R setError(){

        return setOk(null);
    }
    public static R setError(Object data){

        return setError(resultCode.FAIL, "失败", data);
    }
    public static R setError(Integer code,String msg,Object data){
        R r =new R();
        r.setCode(code);
        r.setMsg(msg);
        r.setData(data);
        return r;
    }
    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }
}
